<?php
/**
 * Created by PhpStorm.
 * User: HCDX
 * Date: 2018/5/24
 * Time: 16:12
 */
namespace app\admin\controller;
use think\Controller;
use app\admin\model\Admin as AdminModel;
use app\admin\model;
class Admin extends Controller {
    public function lst()
    {
        return view();
    }

    public function add()
    {
        if(request()->isPost()){
            //获取提交的数据
            $data = input('post.');
            //var_dump($data);die();
            //验证
            $validate = \think\Loader::validate('Admin');
            //进行场景验证
            if(!$validate->scene('add')->check($data)){
                $this->error($validate->getError());
            }
            //实例化model，添加入数据库
            $admin = new AdminModel();
            var_dump($admin);die();
            if($admin->addAdmin($data)){
                //var_dump($admin->addAdmin($data));die();
                $this->success('添加管理员成功',url('lst'));
            }else{
                $this->error('添加管理员失败');
            }
            return ;

        }
        return view();
    }

    public function edit()
    {
        return view();
    }

    public function role()
    {
        return view();
    }
}